package com.wnxy.sddfp.trade.controller;


import com.wnxy.sddfp.common.model.dto.bid.AgencyBidDTO;
import com.wnxy.sddfp.common.model.vo.bid.AgencyBidVo;
import com.wnxy.sddfp.common.result.Result;
import com.wnxy.sddfp.trade.service.IAgencyBidService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 投资机构投资申购表
 */
@RestController
@Api(tags = "投资机构投资申购表")
public class AgencyBidController {

    private final IAgencyBidService agencyBidService;
    public AgencyBidController(IAgencyBidService agencyBidService) {
        this.agencyBidService = agencyBidService;
    }


    /**
     * 机构投资申购
     */
    @ApiOperation("机构投资申购记录")
    @PostMapping("/trade/agency/bid/add")
    public Result<AgencyBidVo> addAgencyBid(@RequestBody AgencyBidDTO agencyBidDTO) {
        AgencyBidVo agencyBidVo = agencyBidService.addAgencyBid(agencyBidDTO);
        return Result.ok(agencyBidVo);
    }

    @ApiOperation("审核借款项目放款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "borrowRecordId", value = "借款项目id"),
            @ApiImplicitParam(name = "status", value = "借款记录的审核状态"),
            @ApiImplicitParam(name = "commission", value = "平台佣金")
    })
    @PutMapping("/trade/agency/bid/status")
    public Result<String> agencyBidStatus(
            Long borrowRecordId,String status,String commission) {
        String result = agencyBidService.borrowRecordStatus(
                borrowRecordId,status,commission);
        return Result.ok(result);
    }
}

